package org.ruwang.springai_hello.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class MvcConfiguration implements WebMvcConfigurer {

    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**") //适用于所有路径
                .allowedOrigins("*") //运行哪些外部域名发起请求
                .allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS") //允许这些HTTP方法的请求通过
                .allowedHeaders("*") //允许所有的请求头
                .exposedHeaders("Content-Disposition"); //响应中允许暴露给客户端的头信息
    }
}
